package cc.aiee.wxpay.model.score.complete;

import java.math.BigDecimal;

import javax.validation.constraints.NotBlank;

import cc.aiee.core0.bean.AmountFormat;
import cc.aiee.core0.bean.DateFormat;
import cc.aiee.core0.enums.AmountUnit;
import cc.aiee.core0.enums.DateUnit;
import cc.aiee.core0.kit.KitDate;
import cc.aiee.core0.kit.KitMoney;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;

@Data
@AllArgsConstructor
@RequiredArgsConstructor
@NoArgsConstructor
public class WxPayPostPayment {

	/**
	 * 付费项目名称<br>
	 * 相同订单号下不能出现相同的付费项目名称，当参数长度超过20个字符时，报错处理。<br>
	 * 示例值：就餐费用, 服务费
	 */
	@NotBlank
	@NonNull
	private String name;

	@NonNull
	private Integer amount;

	private String description;

	private Integer count;

	/**
	 * 示例: 1元/60分钟,租借5分钟内免费,日封顶20元,总封顶99元
	 * 
	 * @param unit_price     单价
	 * @param unit_minute    分钟
	 * @param free_Minute    免费分钟
	 * @param top_DayMoney   日封顶
	 * @param top_TotalMoney 总封顶
	 */
	public void setDescription(float unit_price, float unit_minute, float free_Minute, float top_DayMoney,
			float top_TotalMoney) {
		String unitPrice = KitMoney.formatUp(new AmountFormat(new BigDecimal(unit_price), AmountUnit.YUAN))
				.getFenChineseStr(true);
		String unitMinute = KitDate.formatUp(new DateFormat(new BigDecimal(unit_minute), DateUnit.MINUTE))
				.getTimeChineseStr(1);
		String freeMinute = KitDate.formatUp(new DateFormat(new BigDecimal(free_Minute), DateUnit.MINUTE))
				.getTimeChineseStr(0);
		String topDayMoney = KitMoney.formatUp(new AmountFormat(new BigDecimal(top_DayMoney), AmountUnit.YUAN))
				.getFenChineseStr(true);

		StringBuilder sbl = new StringBuilder();
		sbl.append(unitPrice).append("/").append(unitMinute).append(",租借").append(freeMinute).append("内免费,日封顶")
				.append(topDayMoney);
		this.description = sbl.toString();
	}
}
